//
//  AddTextContentCell.m
//  MIDI
//
//  Created by 邵子凡 on 15/10/29.
//  Copyright © 2015年 QXSX. All rights reserved.
//

#import "AddTextContentCell.h"

@interface AddTextContentCell ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (copy, nonatomic) NSString *placeHolder;

@end

@implementation AddTextContentCell

+(instancetype)cellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"AddTextContentCell";
    AddTextContentCell  *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AddTextContentCell" owner:nil options:nil]firstObject] ;
        
    }
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    return cell;
}

- (void)awakeFromNib {
    
    self.textView.delegate = self;
    self.textView.textColor = [UIColor blackColor];
    self.placeHolder = @"请输入正文内容";
}

//textView编辑开始的时候
- (void)textViewDidBeginEditing:(UITextView *)textView{
    
    textView.text = @"";
    
}

//textView编辑结束的时候
- (void)textViewDidEndEditing:(UITextView *)textView{
    
    if ([textView.text isEqualToString:@""]){
        textView.text = self.placeHolder;
    }
    
    //传代理
    if ([self.delagate respondsToSelector:@selector(upLoadContent:)]) {
        [self.delagate upLoadContent:textView.text];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
